package com.winqai.security.core.authentication;


import com.winqai.security.core.properties.SecurityConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;

public class AbstractChannelSecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    private AuthenticationSuccessHandler winqaiAuthenticationSuccessHandler;

    @Autowired
    private AuthenticationFailureHandler winqaiAuthenticationFailureHandler;

    protected void applyPasswordAuthentiationConfig(HttpSecurity http) throws Exception {
        http.formLogin()
                .loginPage(SecurityConstants.DEFAULT_UNAUTHENTICATION_URL)
                .loginProcessingUrl(SecurityConstants.DEFAULT_LOGIN__PROCESSING_URL)
                .successHandler(winqaiAuthenticationSuccessHandler)
                .failureHandler(winqaiAuthenticationFailureHandler);
    }
}
